package main.java.responsibilitychain;

/**
 * @author xin麒
 * @date 2023/2/3 11:21
 */
public abstract class MyAbstractHandler {
    private MyAbstractHandler nextHandler;

    public void filter(MyRequest myRequest, MyResponse myResponse) {
        doFilter(myRequest, myResponse);
        if (getNextHandler() != null) {
            getNextHandler().filter(myRequest, myResponse);
        }
    }

    public MyAbstractHandler getNextHandler() {
        return nextHandler;
    }

    public void setNextHandler(MyAbstractHandler nextHandler) {
        this.nextHandler = nextHandler;
    }

    public abstract void doFilter(MyRequest myRequest, MyResponse myResponse);
}
